package com.rt.easyjava.base.modules.timerjob.service.job;

import com.rt.easyjava.base.modules.timerjob.dto.TmptTimerBizDto;
import com.rt.easyjava.common.utils.others.DateTool;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.PersistJobDataAfterExecution;
import org.springframework.scheduling.quartz.QuartzJobBean;

/**
 * @Description: Quartz job类
 * @Author: yanhonghai
 * @Date: 2018/11/16 14:47
 */
@PersistJobDataAfterExecution//持久化
@DisallowConcurrentExecution//禁止并发执行(Quartz不要并发地执行同一个job定义（这里指一个job类的多个实例）)
@Slf4j
public class MyQuartzJobBean extends QuartzJobBean {

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {

        TmptTimerBizDto tmptTimerBizDto = (TmptTimerBizDto)context.getMergedJobDataMap().get("tmptTimerBizDto");
        String className = tmptTimerBizDto.getClassName();
        String param = tmptTimerBizDto.getParam();

        log.info("---> Quartz job1， key={},  {}", context.getTrigger().getKey(), DateTool.getCurrentDateStr1("yyyy-MM-dd HH:mm:ss.SSS"));
        log.info(param);
    }

}
